exports.getUrl = async (context) => {
    const cloud = context.cloud;
    const env = context.data.env;
    if(!env) {
      return { success: false, data: error, message: "请上传env参数" }
    }
    const urlobj = {
      "10002":"https://m.duanqu.com/?_ariver_appid=3000000053747493&_mp_code=tb&transition=present",
      "10003":"https://m.duanqu.com?_ariver_appid=3000000048426063&nbsv=2.4.94&nbsource=debug&nbsn=TRIAL&_mp_code=tb&transition=present",
      "10014":"https://m.duanqu.com/?_ariver_appid=3000000053749622&_mp_code=tb&transition=present"
    }
    try {
        //查询数据库商家的session信息
        const result = await cloud.db.collection('c_key').find({
            name: 'url',
            type: 'common',
            env
        });
        if(result.length>0) {
          return { success: true, data: {
            url:result[0],
            openId:context.openId,
            currentTime: Date.now()
          }, message: "请求成功" }
        }
        return { success: true, data: {
            url:urlobj,
            openId:context.openId,
            currentTime: Date.now()
          }, message: "请求成功" }
    } catch (error) {
        return { success: false, data: error, message: "系统错误" }
    }
};